import os.path

from fastapi import APIRouter
from sympy.integrals.meijerint_doc import category

from config.config import config

from schema.inquiry import InquiryBaseResoponse
from service.inquiry_service import Inquiry_Service

router = APIRouter()
inquiry_service = Inquiry_Service()

@router.post("/inquiry_by_material", response_model=InquiryBaseResoponse)
async def inquiry_by_material(material_text: str):
    try:
        rule_path = os.path.join(config.DATA_DIR, "rules_query_merged.json")
        category_path = os.path.join(config.DATA_DIR, "rules_sample.json")
        response = inquiry_service.inquiry(rule_path, category_path, material_text)
        return InquiryBaseResoponse(success=True, message="Success", data=response)
    except Exception as e:
        return InquiryBaseResoponse(success=False, message=str(e), data=None)

